package levelloader
{
	import feathers.layout.TiledColumnsLayout;
	
	import starling.display.Sprite;

	public class LayerData
	{
		private var _layoutData:Vector.<Vector.<TileData>>;
		private var _layerData:Array = new Array();
		
		public function LayerData(data:Array, map:TiledMap=null):void
		{
			var width:uint = map.mapWidth();
			var height:uint = map.mapHeight();
			
			_layerData = data;
			_layoutData = new Vector.<Vector.<TileData>>(width, true);
			
			for(var x:uint = 0; x < width; ++x)
			{
				var layoutColumn:Vector.<TileData> = new Vector.<TileData>();
				for(var y:uint = 0; y < height; ++y)
				{
					var val:int = data[x+y*width];
					if(val != 0)
					{
						layoutColumn.push(new TileData(x, y, val));
					}
				}
				_layoutData[x] = layoutColumn;
			}
		}
		
		public function getRawData():Array
		{
			return _layerData;
		}
		
		public function getData():Vector.<Vector.<TileData>>
		{
			return _layoutData;
		}		
	}	
}
